package com.jintian.smart.kernel.core.flow;

import com.jintian.smart.kernel.core.annotation.flow.TaskOperate;

import java.util.Map;

public interface ITaskOperation<T> {
    public final static String FORMURL_PARAM_BUSINESS_ID = "id";
    public final static String FORMURL_PARAM_BUSINESS_KEY = "key";
    public final static String FORMURL_PARAM_PROCESS = "process";
    public final static String FORMURL_PARAM_ACTIVITY = "activity";
    public final static String FORMURL_PARAM_ACTIVITYLABEL = "activityLabel";
    public final static String FORMURL_PARAM_PROCESSINSTANCEID = "pid";
    public final static String FORMURL_PARAM_TASKID = "tid";
    public final static String FORMURL_PARAM_DO = "do";

    /**
     * 完成
     *
     * @param taskId
     * @param processControl
     * @return
     */
    @TaskOperate
    T complete(String taskId, ProcessControl processControl) throws Exception;

    /**
     * 回退
     *
     * @param taskId
     * @param processControl
     * @return
     */
    @TaskOperate
    T fallback(String taskId, ProcessControl processControl) throws Exception;

    /**
     * 抢占/办理
     *
     * @param taskId
     * @return
     */
    @TaskOperate
    void claim(String taskId, ProcessControl processControl) throws Exception;

    /**
     * 取消办理
     *
     * @param taskId
     * @param processControl
     */
    @TaskOperate
    void unclaim(String taskId, ProcessControl processControl) throws Exception;

    /**
     * 转发
     *
     * @param taskId
     * @param processControl
     */
    @TaskOperate
    T transform(String taskId, ProcessControl processControl) throws Exception;

    /**
     * 取回
     *
     * @param taskId
     * @param processControl
     * @throws Exception
     */
    @TaskOperate
    void withdraw(String taskId, ProcessControl processControl) throws Exception;

    /**
     * 终止
     *
     * @param taskId
     * @param processControl
     */
    @TaskOperate
    void abort(String taskId, ProcessControl processControl) throws Exception;

    /**
     * 挂起
     *
     * @param taskId
     * @param processControl
     */
    @TaskOperate
    T suspend(String taskId, ProcessControl processControl) throws Exception;

    /**
     * 解挂
     *
     * @param taskId
     * @param processControl
     */
    @TaskOperate
    T resume(String taskId, ProcessControl processControl) throws Exception;

    /**
     * 注册动作实现覆盖默认实现
     *
     * @param action
     * @param ITaskAction
     */
    void registerTaskAction(FlowAction action, ITaskAction<T> ITaskAction);

    @TaskOperate
    String formUrl(String taskId) throws Exception;

    @TaskOperate
    ProcessControl queryProcessControl(String taskId, String action, Map<String, Object> transientVariables) throws Exception;
}
